package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.Role;
import com.itheima.health.vo.MenuVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleMapper extends BaseMapper<Role> {

    @Select("select permission_id " +
            "from t_role_permission " +
            "where role_id=#{id}")
    int[] findPermissionIdsbyRoleId(int id);

    @Insert("insert into t_role_permission values(#{gid},#{permissionId})")
    void addRoleAndPermissionId(@Param("gid") Integer gid, @Param("permissionId") Integer permissionId);

    @Delete("delete from t_role_permission where role_id=#{id}")
    void deletePermissionInfoByRoleId(Integer id);

    @Select("select * from t_menu")
    List<MenuVO> findMenuAll();

    @Select("select menu_id " +
            "from t_role_menu " +
            "where role_id=#{id}")
    int[] findMenuIdsbyRoleId(int id);

    @Delete("delete from t_role_menu where role_id=#{id}")
    void deleteMenuInfoByRoleId(Integer id);

    @Insert("insert into t_role_menu values(#{gid},#{menuId})")
    void addRoleAndMenuId(Integer gid, Integer menuId);
}
